package com.mgface.mrmdb.reids;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.StringRedisTemplate;

public class RedisSentinelTest {
	
	public static void main(String[] args) throws InterruptedException {
		@SuppressWarnings("resource")
		ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:spring-redis.xml");
		StringRedisTemplate stringRedisTemplate = context.getBean("stringRedisTemplate",StringRedisTemplate.class);
		System.out.println(stringRedisTemplate);
		// String读写
		stringRedisTemplate.delete("myStr");
		stringRedisTemplate.opsForValue().set("myStr", "000");
		System.out.println(stringRedisTemplate.opsForValue().get("myStr"));
		//模拟切换主机
		Thread.sleep(20000);
		stringRedisTemplate.opsForValue().set("myStr3", "111");
		System.out.println(stringRedisTemplate.opsForValue().get("myStr3"));
	}

}
